change attrs to dataclasses - #521
Conversation
|
This is ready for a first look. |
inducer
left a comment
There was a problem hiding this comment.
Thanks for getting this started. Two points to work on below.
| attrs.field(validator=attrs.validators.instance_of(immutabledict)) | ||
| index_to_access_descr: Mapping[str, EinsumAxisDescriptor] = \ | ||
| attrs.field(validator=attrs.validators.instance_of(immutabledict)) |
There was a problem hiding this comment.
Validation can happen as part of __post_init__.
There was a problem hiding this comment.
Done in 2da059ea
|
|
||
|
|
||
| @attrs.frozen(eq=False, repr=False, hash=True, cache_hash=True) | ||
| @dataclasses.dataclass(frozen=True, eq=False, repr=False, unsafe_hash=True) |
There was a problem hiding this comment.
Where applicable, all array-like dataclasses should use the same, unparametrized decorator.
That same decorator should also generate code for a cached hash function. (Maybe this can be factored out into a separate function?) Example: https://github.com/inducer/pymbolic/pull/125/files#diff-768f1abbde39f5f7efff7c209a95315a87e28e0ba4f42e7a468903203aba8ffcR718
|
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
7bb8628 to
95c71be
Compare
| _data: Mapping[str, Array] = attrs.field( | ||
| validator=attrs.validators.instance_of(immutabledict)) | ||
| _data: Mapping[str, Array] |
There was a problem hiding this comment.
I can't get this particular validator to work; why should _data be an immutable dict here?
|
This is ready for review. |
|
Thanks! |
* change attrs to dataclasses * post-merge fix * more fixes * switch to array_dataclass * use _augment_array_dataclass * restore attribute validation * mypy? * Disable pylint invalid-field-call --------- Co-authored-by: Andreas Kloeckner <inform@tiker.net>
Closes #370.
TODOs:
Please squash